#ifndef _THREADPOOL_H
#define _THREADPOOL_H

#include "TaskQueue.h"
#include <thread>
#include <vector>
#include <unistd.h>

using std::vector;
using std::thread;

class ThreadPool{
private:
    size_t m_threadNum;
    vector<thread> m_threads;
    size_t m_queSize;
    TaskQueue m_que;
    bool m_isExit;

    ElemType getTask();
    void doTask();

public:
    ThreadPool(size_t threadNum,size_t queSize);
    ~ThreadPool();
    void start();
    void stop();
    void addTask(ElemType &&ptask);

};


#endif //_THREADPOOL_H
